<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="fade-obj">+1</div>
<button id="fade-btn">淡出</button>
<script>
    var oDiv = document.getElementById("fade-obj");
    var fadeBtn = document.getElementById("fade-btn");
    var opacity = 1;
    fadeBtn.onclick = change;
    function change() {
        if(opacity)
        {
            setTimeout(change,50);
            opacity = Math.floor((opacity - 0.08)*100)/100;
            oDiv.text.style.opacity = opacity.toString();
        }
    }
</script>
</body>
</html>
